# 继承
# 定义一个父类Animal
class Animal:
    def __init__(self, name):
        self.name = name

    def speak(self):
        print("Animal is speaking")


# 定义一个子类Dog，继承自Animal 单继承
class Dog(Animal):
    def __init__(self, name, breed):
        super().__init__(name)
        self.breed = breed

    def speak(self):
        print("Dog is barking")

    def wag_tail(self):
        print("Dog is wagging its tail")

# 创建一个Dog对象
dog = Dog("Buddy", "Golden Retriever")
print(dog.name)  # 输出：Buddy
print(dog.breed)  # 输出：Golden Retriever
dog.speak()  # 输出：Dog is barking
dog.wag_tail()  # 输出：Dog is wagging its tail



